// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init({
  env:'cloud1-2g6vpgs796710242'
})

exports.main = async () => {
  const db = cloud.database()
  let count =  await db.collection('Rank')
  // .aggregate()
  // .sort({
  //   count:-1
  // })
  // .end()
  .orderBy("count","desc")
  .count()
  count = count.total
  let all=[]
  for (let i=0; i<count; i+=20) {
    let list = await db.collection("Rank").skip(i).get()
    all = all.concat(list.data)
  }
  return all;
}